#include <iostream>
#include <string.h>
using namespace std;

/*
    【题目192】创建一个employee类，该类中有字符数组，表示姓名、街道地址、市、省和邮政编码。
    把表示构造函数、changname(、display()的函数的原型放在类定义中，构造函数初始化每个成员，display(函数把完整的对象数据打印出来。
    其中的数据成员是保护的，函数是公有的。
*/

class employee
{
public:
    employee(char *n, char *s, char *c, char *p, char *z);
    void changeName(char *n);
    void display();
private:
    char name[20];
    char street[20];
    char city[20];
    char province[20];
    char postalCode[20];
};

employee::employee(char *n, char *s, char *c, char *p, char *z)
{
    strcpy(name, n);
    strcpy(street, s);
    strcpy(city, c);
    strcpy(province, p);
    strcpy(postalCode, z);
}

void employee::changeName(char *n)
{
    strcpy(name, n);
}

void employee::display()
{
    cout << "姓名: " << name << endl;
    cout << "街道地址: " << street << endl;
    cout << "市: " << city << endl;
    cout << "省: " << province << endl;
    cout << "邮政编码: " << postalCode << endl;
}  

int main()
{
    char name[20], street[20], city[20], province[20], postalCode[20];
    strcpy(name, "Tom");
    strcpy(street, "123 Main St.");
    strcpy(city, "Toronto");
    strcpy(province, "Ontario");
    strcpy(postalCode, "M1M1M1");
    employee emp(name, street, city, province, postalCode);
    emp.display();
    char newName[20];
    strcpy(newName, "Jerry");
    emp.changeName(newName);
    emp.display();

    

    return 0;
}